/**
  * 用户登录
  * @module 用户登录
 * @author 徐灿
 * @date 2018-9-6
  */
'use strict';

const crypto = require('crypto');
const conn = require('../../libs/Conn');
const util = require('../../libs/Utils');

module.exports = async function (params) {
    let login_name = params.login_name;
    let password = util.encrypt(params.password);
    let userResult = await conn(`SELECT
                                      uf.*,
                                      ug.is_manager
                                    FROM
                                        user_file uf
                                    LEFT JOIN user_group ug ON uf.group_id = ug.group_id AND ug.delete_sign = 1
                                    WHERE
                                        login_name = '${login_name}'
                                    AND PASSWORD = '${password}'
                                    AND uf.delete_sign = 1`);

    return userResult[0];
};